{include file="public/js_css" /}

<body class="childrenBody">
<form class="layui-form" style="width:80%;">
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">登录账号</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input account" lay-verify="required" placeholder="请输入登录账号">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input nickname" lay-verify="required" placeholder="请输入姓名">
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <label class="layui-form-label">邮箱</label>
        <div class="layui-input-block">
            <input type="text" class="layui-input userEmail" lay-verify="email" placeholder="请输入邮箱">
        </div>
    </div>
    <!--<div class="layui-form-item layui-row layui-col-xs12">-->
    <!--<label class="layui-form-label">登录密码</label>-->
    <!--<div class="layui-input-block">-->
    <!--<input type="password" class="layui-input password" lay-verify="password" placeholder="登录密码">-->
    <!--</div>-->
    <!--</div>-->
    <div class="layui-row">
        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block userSex">
                <input type="radio" name="sex" value="1" title="男" checked>
                <input type="radio" name="sex" value="0" title="女">
                <input type="radio" name="sex" value="3" title="未知">
            </div>
        </div>
        <div class="magb15 layui-col-md4 layui-col-xs12">
            <label class="layui-form-label">会员状态</label>
            <div class="layui-input-block">
                <select name="userStatus" class="userStatus" lay-filter="userStatus">
                    <option value="0">未启用</option>
                    <option value="1">启用</option>
                    <option value="3">禁用</option>
                </select>
            </div>
        </div>
    </div>
    <div class="layui-form-item layui-row layui-col-xs12">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="addUser">立即添加</button>
            <button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form;
        var addUrl = '{:url("userAdd")}';

        layer = parent.layer === undefined ? layui.layer : top.layer,
            $ = layui.jquery;

        form.on("submit(addUser)", function (data) {
            //弹出loading
            var index = top.layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.001});
            // 实际使用时的提交信息
            $.post(addUrl, {
                userName: $(".userName").val(),  //登录名
                userEmail: $(".userEmail").val(),  //邮箱
                userSex: data.field.sex,  //性别
                userGrade: data.field.userGrade,  //会员等级
                userStatus: data.field.userStatus,    //用户状态
                newsTime: submitTime,    //添加时间
                userDesc: $(".userDesc").text(),    //用户简介
            }, function (res) {
                if (res.code == 0) {
                    layer.msg(res.msg, {icon: 6});
                    setTimeout(function () {
                        top.layer.close(index);
                        layer.closeAll("iframe");
                        parent.location.reload();
                    }, 3000);
                } else {
                    layer.msg(res.msg, {icon: 5});

                }

            });

            return false;
        })

        //格式化时间
        function filterTime(val) {
            if (val < 10) {
                return "0" + val;
            } else {
                return val;
            }
        }

        //定时发布
        var time = new Date();
        var submitTime = time.getFullYear() + '-' + filterTime(time.getMonth() + 1) + '-' + filterTime(time.getDate()) + ' ' + filterTime(time.getHours()) + ':' + filterTime(time.getMinutes()) + ':' + filterTime(time.getSeconds());

    })
</script>
<script type="text/javascript" src="__STATIC__/admin/js/user/userAdd.js"></script>
</body>